package com.endurance.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @Value("${server.port}")
    private int port;

    @GetMapping("/findAll")
    public HashMap findAll(HttpServletRequest request) {

        String header = request.getHeader("X-Request-color");
        System.out.println("header:" + header);

        RestTemplate restTemplate = new RestTemplate();
        HashMap map = restTemplate.getForObject("http://localhost:10004/product/findAll",
                HashMap.class);
        System.out.println("user服务调用product服务返回的数据：" + map);
        return map;
    }

}
